package com.wangxi.boot10pro.mapper;

import com.wangxi.boot10pro.entity.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProMapper {
    @Select("select * from product where title=#{title}")
    Product selectByTitle(String title);

    @Insert("insert into product values(null,#{title},#{price},#{saleCount})")
    void insertPro(Product product);

    @Select("select * from product")
    @Result(column = "sale_count",property = "saleCount")
    List<Product> selectAll();

    @Delete("delete from product where id=#{id}")
    void deleteById(int id);

    @Select("select * from product where id=#{id}")
    @Result(column = "sale_count",property = "saleCount")
    Product selectPro(int id);

    @Update("update product set title=#{title},price=#{price},sale_count=#{saleCount} where id=#{id}")
    void updatePro(Product product);
}
